<template>
  <div class="container">
    <div class="title">
      <span>修改</span>
      <span class="back" @click="back">
        <i class="iconfont icon-fanhui"></i> 返回
      </span>
    </div>
    <el-divider></el-divider>
    <el-form label-width="120px">
      <div class="wrap">
        <el-form-item label="审核状态">
          <el-radio v-model="status" label="2">审核通过</el-radio>
          <el-radio v-model="status" label="3">审核不通过</el-radio>
        </el-form-item>
        <el-form-item label="输入不通过理由" v-if="status === '3'">
          <el-input type="textarea" v-model="sta_msg"></el-input>
        </el-form-item>
        <el-form-item class="submit">
          <el-button type="primary" @click="updateData()">提 交</el-button>
        </el-form-item>
      </div>
    </el-form>
  </div>
</template>

<script>
import Auth from '@/models/auth'

export default {
  components: {},
  props: {
    UserEducationId: {
      type: Number,
    },
  },
  data() {
    return {
      status: '',
      sta_msg: '',
    }
  },
  mounted() {
    this.getInfo()
  },
  methods: {
    async getInfo() {
      const info = await Auth.getEducationInfo(this.UserEducationId)
      this.status = info.status
      this.sta_msg = info.sta_msg
    },
    back() {
      this.$emit('editClose')
    },
    async updateData() {
      const self = this
      if (!self.sta_msg) {
        self.sta_msg = ''
      }
      const info = {
        id: self.UserEducationId,
        status: self.status,
        sta_msg: self.sta_msg,
      }
      const res = await Auth.updateEducation(info)
      if (res.error_code === 0) {
        self.imgValue = []
        this.$message.success(`${res.msg}`)
        this.back()
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.el-divider--horizontal {
  margin: 0;
}

.container {
  .title {
    height: 59px;
    line-height: 59px;
    color: $parent-title-color;
    font-size: 16px;
    font-weight: 500;
    text-indent: 40px;

    .back {
      float: right;
      margin-right: 40px;
      cursor: pointer;
    }
  }

  .wrap {
    padding: 20px;
  }

  .submit {
    float: left;
  }
}
</style>
